﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections.ObjectModel;
using System.Net;
namespace CoffeeManager
{
    public partial class NTPForm : DevExpress.XtraEditors.XtraForm
    {
        ProgessNTP progessNTP;
        MyUtils.ModifyRegistry registry = new MyUtils.ModifyRegistry(); 
        public ProgessNTP ProgessNTP
        {
            get { return progessNTP; }
            set { progessNTP = value; }
        }
        public NTPForm()
        {
            InitializeComponent();
            
            cmblistTimeZone.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            txtTime.Enabled = false;
            cmblistTimeZone.Enabled = false;
            this.Load+=new EventHandler(NTPForm_Load);
            btnCancel.Click+=new EventHandler(btnCancel_Click);
            btnOK.Click+=new EventHandler(btnOK_Click);
        }
        private void NTPForm_Load(object sender, EventArgs e)
        {
              
                 TimeZoneInfo localZone = TimeZoneInfo.Local;
                 ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
                 foreach (var timeZone in timeZones)
                 {
                     cmblistTimeZone.Properties.Items.Add(timeZone);
                     if (timeZone.Equals(localZone))
                     {
                         cmblistTimeZone.SelectedItem = timeZone;
                     }

                 }

                 txtTime.Text = DateTime.Now.ToString();
           
             

        }
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            //Write regedit , checked NPT
            //registry.Write(MyUtils.ConstString.REGEDIT_CHECK_NTP, 1);
            ProgessNTP pg = new ProgessNTP();
            pg.NtpForm = this;
            pg.ShowDialog();
            
        }
    }
}
